<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<base href="<%=basePath%>" />
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript" language="JavaScript">
	function validate(){
		var loginname = document.getElementById("loginname").value;
		if(null ==loginname || ""==loginname){
			alert("用户名不能为空");
			return false;
		}
	}
	function go(){
		var forward = document.getElementById("forward").value;
		window.location = "loginSer?ope=queryByPage&pageNum="+forward;
	}
</script>
<body>
<table border="1" style="width:100%;text-align:center">
	<caption>用户信息展示</caption>
	<tr>
		<td colspan='7'>
		<form action="loginSer" onSubmit="return validate();"> 
			<input type="hidden" name="ope" value="queryByPage">
			登录名:<input type="text" name="loginname" value="${loginname}" id="loginname">
			<input type="submit" value="查询">
			<a href="loginSer?ope=queryByPage&&showAll=true">清空</a>
		</form>
		</td>
	</tr>
	<tr>
		<th>序号</th>
		<th>id</th>
		<th>登录名</th>
		<th>用户名</th>
		<th>性别</th>
		<th>年龄</th>
		<th>操作</th>
	</tr>
	<c:forEach items="${pageUtil.list }" var="temp" varStatus="var">
		<tr>
			<td>${var.count+pageUtil.rowNum}</td>
			<td>${temp.id}</td>
			<td>${temp.loginName}</td>
			<td>${temp.userName}</td>
			<td>${temp.sex}</td>
			<td>${temp.age}</td>
			<td>
				<a href="loginSer?ope=viewUser&id=${temp.id}">查看</a>
				<a href="loginSer?ope=editUser&id=${temp.id}">修改</a>
				<a href="loginSer?ope=delUser&id=${temp.id}&pageNum=${pageUtil.pageNum}">删除</a>
			</td>
		</tr>
	</c:forEach>
	<tr>
		<td colspan='7'>
			<c:if test="${pageUtil.pageNum != 1 }">
				<a href="loginSer?ope=queryByPage&pageNum=1">首页</a>
				<a href="loginSer?ope=queryByPage&pageNum=${pageUtil.pageNum-1 }">上一页</a>
			</c:if>
			<c:forEach begin='${pageUtil.everyPageStart }' end='${pageUtil.everyPageEnd }' var="temp">
				<c:choose>
					<c:when test="${pageUtil.pageNum == temp }">${temp }</c:when>
					<c:otherwise><a href="loginSer?ope=queryByPage&pageNum=${temp}">${temp }</a></c:otherwise>
				</c:choose>
			</c:forEach>
			<c:if test="${pageUtil.pageNum != pageUtil.pageCount && pageUtil.pageCount != 0}">
				<a href="loginSer?ope=queryByPage&pageNum=${pageUtil.pageNum+1 }">下一页</a>
				<a href="loginSer?ope=queryByPage&pageNum=${pageUtil.pageCount }">尾页</a>
			</c:if>
			</br>
			总数据量：${pageUtil.rowCount }  当前页数：${pageUtil.pageNum }/${pageUtil.pageCount }
			</br>
			<input type="text" name="forward" id='forward' value="${pageUtil.pageNum }">
			<input type="button" value="跳转" onclick="go()">
		</td>
	</tr>
</table>
</body>
</html>